import static org.junit.Assert.*;

/**
* @author Irina
*/
public class CoffeeMakerTest extends TestCase {
private CoffeeMaker cm;
private Inventory i;
private Recipe r1;
private Recipe r2;

public void setUp() {
cm = new CoffeeMaker();
i = cm.checkInventory();

r1 = new Recipe();
r1.setName("Coffee");
r1.setPrice(50);
r1.setAmtCoffee(6);
r1.setAmtMilk(1);
r1.setAmtSugar(1);
r1.setAmtChocolate(0);

/*r2 = new Recipe();
r2.setName("Chocolate");
r2.setPrice(20);
r2.setAmtCoffee(0);
r2.setAmtMilk(1);
r2.setAmtSugar(1);
r2.setAmtChocolate(1);*/
}

public void testAddRecipe1() {
assertTrue(cm.addRecipe(r1));
}
//Check if the recipe already exists then return false
public void testAddRecipe_false() {
assertTrue(cm.addRecipe(r1));
assertFalse(cm.addRecipe(r1));

}
public void testDeleteRecipe1() {
cm.addRecipe(r1);
assertTrue(cm.deleteRecipe(r1));
}

public void testEditRecipe1() {
cm.addRecipe(r1);
Recipe newRecipe = new Recipe();
newRecipe = r1;
newRecipe.setAmtSugar(2);
assertTrue(cm.editRecipe(r1, newRecipe));
}
//--
public void testEditRecipefalse() {
cm.addRecipe(r1);
cm.addRecipe(r1);
//cm1.deleteRecipe(r1);
assertTrue(cm.editRecipe(r1,r1));
}
public void testGetRecipes(){

cm.addRecipe(r1);
//cm.addRecipe(r2);
assertEquals(r1,cm.getRecipes());
}
// att
public void testGetRecipeForName() {
cm.addRecipe(r1);
//r1.getRecipeForName("Coffee");
assertEquals(r1,cm.getRecipeForName("Coffee"));
}
//Check if the recipe already exists then return false
public void testAddRecipe2_false() {
assertTrue(cm.addRecipe(r1));
assertFalse(cm.addRecipe(r1));

}
public void testDeleteRecipe2() {
cm.addRecipe(r1);
assertTrue(cm.deleteRecipe(r1));
}

public void testEditRecipe2() {
cm.addRecipe(r1);
Recipe newRecipe = new Recipe();
newRecipe = r1;
newRecipe.setAmtSugar(2);
assertTrue(cm.editRecipe(r1, newRecipe));
}
//tests if adds inventory correctly
public void testAddInventory() {
cm.addInventory(1, 1, 1, 0);
//Inventory nvntry = cm.checkInventory();
assertEquals(15, i.getCoffee());
assertEquals(15, i.getMilk());
assertEquals(15, i.getSugar());
assertEquals(15, i.getChocolate());
} 

//tests if purchased with enough money and returns change 
public void testMakeCoffee() { 
int change = cm.makeCoffee(r1, 60);
assertEquals(10, change); 
}
// tests if not enough money
public void testMakeCoffee_invalid()
{
int change = cm.makeCoffee(r1, 5);
assertEquals(5, change); 
} 


}
